package com.greateamd.timetableasy.client.widgets.campus;

import java.util.ArrayList;
import java.util.List;

import com.greateamd.timetableasy.client.widgets.ListBox;
import com.greateamd.timetableasy.domain.Campus;

public class CampusContainer extends ListBox {

	List<Campus> campuses = new ArrayList<Campus>();
	
	public void addCampus(Campus campus){
		if(!campuses.contains(campus.getName())){
			campuses.add(campus);
			addItem(campus.getName());
		}
	}
	
	public Campus getSelectedCampus(){
		return campuses.get(getSelectedIndex());
	}
	
	public void removeSelectedCampus(){
		if(getSelectedIndex()!= -1){
			campuses.remove(getSelectedIndex());
			removeItem(getSelectedIndex());
		}
	}
	
	public List<Campus> getCampus(){
		return campuses;
	}
}
